﻿@using KaytechSoftware.Cms.App.Common
@model KaytechSoftware.Cms.App.Areas.Admin.Models.Base.GridModel

@{ var filters = Model.Filters.GetDetails();}
@if (filters != null && filters.FilterDescriptors.Any())
{
    using (Html.BeginForm("List", Model.ControllerName, FormMethod.Post))
    {
         <div class="form filters">
             @Html.Hidden("ControllerName", Model.ControllerName)
             @foreach (var descriptor in filters.FilterDescriptors)
             {
                 switch (descriptor.Renderer)
                 {
                     case RendererType.Hidden:
                         <div class="form-row">
                             @Html.Hidden(descriptor.Name, descriptor.TextValue)
                         </div>
                         break;
                     case RendererType.TextBox:
                         <div class="form-row">
                             <span class="filter-label">@descriptor.LabelResourceKey:</span>
                             @Html.TextBox(descriptor.Name, descriptor.TextValue)
                         </div>
                         break;
                     case RendererType.TextArea:
                         <div class="form-row">
                             <span class="filter-label">@descriptor.LabelResourceKey:</span>
                             @Html.TextArea(descriptor.Name, descriptor.TextValue)
                         </div>
                         break;
                     case RendererType.DropDown:
                         <div class="form-row">
                             <span class="filter-label">@descriptor.LabelResourceKey:</span>
                             @Html.DropDownList(descriptor.Name, descriptor.Items)
                         </div>
                         break;
                 }
             }
         
             <div class="form-row">
                 <input class="filter-button" type="submit" value="Filter"/>
             </div>
        </div>
     }
}